import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;

[Bindable]
private var topTracks:ArrayCollection;

private function handleTopTracks(event:ResultEvent):void
{
	topTracks = new ArrayCollection();
	var xmlResult:XML = new XML(event.result);
	for each(var t:XML in xmlResult.Track){
    	topTracks.addItem(t);
    }
}

private function loadTopTracks():void
{
	topTracksXml.send();
}

public function loadTrack(id:int):void
{
	topTracksView.selectedIndex = 1;
	
	if ( trackImg != null )
		trackImg.source = topTracks[id].Thumbnail.Large;
	if ( trackTitle != null )
		trackTitle.text = topTracks[id].Title;
	if ( trackArtist != null )
		trackArtist.text = topTracks[id].Artist;
	if ( trackRank != null )
		trackRank.text = "Rank " + topTracks[id].Rank;
}